package com.nb.controller;

import com.nb.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class HelloController  {
    //真实访问地址：项目名/HelloController/hello
    @RequestMapping("/hello")
    public String hello(Model model){
        //封装数据，向模型中添加属性msg和值，可以再jsp中取出并渲染
        model.addAttribute("msg","helloSpringmvc");
        //WEB-INF/jsp/hello.jsp
        return "hello";///会被视图解析器处理，拼接为url
    }
    //接受前端穿过来的参数  localhost:8080/h2
    @RequestMapping("/h2")
    public String test(User user){
        System.out.println(user);
        return "hello";//转发到hello.jsp
    }
}
